<template>
	<view class="drawresult" v-if="showDrawInfo">
		<view class="drawresult_top">
			<view class="f-18 f-w">{{lotteryinfo.gifts}}</view>
			<image class="prize_img" :src="picUrl+lotteryinfo.gifts_pic" mode="aspectFit"></image>
		</view>

		<view class="address_info_box">
			<view class="address_info_title f-w">奖品信息</view>
			<view class="address_info">
				<view class="display_flex mt-20">
					<view class="flex-1 f-13 text-l" style="width: 255rpx;">用户名</view>
					<view class="c-999999 f-12">{{lotteryinfo.user_name}}</view>
				</view>
				<view class="display_flex mt-20">
					<view class="flex-1 f-13 text-l" style="width: 255rpx;">手机号</view>
					<view class="c-999999 f-12">{{lotteryinfo.mobile}}</view>
				</view>
				<view class="display_flex mt-20">
					<view class="flex-1 f-13 text-l" style="width: 255rpx;">领取地址</view>
					<view class="c-999999 f-12">{{lotteryinfo.company_name}}</view>
				</view>
				<view class="display_flex mt-20">
					<view class="flex-1 f-13 text-l" style="width: 255rpx;">发放状态</view>
					<view class="c-00A0DC f-12" v-if="lotteryinfo.gifts_status==1">未发放</view>
					<view class="c-red f-12" v-else>已发放</view>
				</view>
				<view v-if="lotteryinfo.gifts_status==1" class="group_public_btn_block mt-40"
					@click="huodonglotteryGiftsValidate">发放礼品</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		huodonglotteryGiftsValidateInfo,
		huodonglotteryGiftsValidate
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				lotteryinfo: '',
				showDrawInfo: false,
				haveAddress: true,
				user_id: '',
				picUrl: app.globalData.picUrl,
				onlinePic: app.globalData.onlinePic,
			};
		},
		onShow() {
			if (!uni.getStorageSync('access_token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			} else {
				if (uni.getStorageSync('onload')) {
					this.huodonglotteryGiftsValidateInfo()
				}
			}
		},
		onLoad: function(options) {
			this.user_id = decodeURIComponent(options.scene)
			if (uni.getStorageSync('access_token')) {
				this.huodonglotteryGiftsValidateInfo()
			}
		},
		methods: {
			huodonglotteryGiftsValidateInfo() {
				huodonglotteryGiftsValidateInfo({
					user_id: this.user_id
				}).then(res => {
					if (res.state == 1) {
						this.showDrawInfo = true
						this.lotteryinfo = res.data.info

					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},

			huodonglotteryGiftsValidate() {
				huodonglotteryGiftsValidate({
					user_id: this.user_id,
				}).then(res => {
					if (res.state == 1) {
						uni.showToast({
							title: '发放成功',
							icon: 'none',
							duration: 1500
						});
						this.huodonglotteryGiftsValidateInfo()
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
		},
		onShareAppMessage(res) {
			app.getShareTask()
			return {

			}
		}
	}
</script>

<style lang="scss">
	.drawresult {
		.drawresult_top {
			padding: 60rpx 30rpx 80rpx 30rpx;
			background-color: #FAFAFA;
			text-align: center;
		}

		.prize_img {
			width: 306rpx;
			height: 180rpx;
			margin-top: 40rpx;
		}

		.addressform_box {
			padding: 38rpx 60rpx;

			.addressform_cell {
				margin-top: 40rpx;
				display: flex;
				align-items: center;

				.addressform_lable {
					width: 110rpx;
					font-size: 26rpx;
					text-align: left;
					margin-right: 20rpx;
				}

				.addressform_input_box {
					flex: 1;
					padding: 20rpx 30rpx;
					border-radius: 8rpx;
					border: 1rpx solid #E9E9E9;

					.addressform_input {
						font-size: 26rpx;
					}
				}

				.addressform_textarea_box {
					flex: 1;
					padding: 30rpx 20rpx;
					border-radius: 8rpx;
					border: 1rpx solid #E9E9E9;

					.addressform_textarea {
						width: 100%;
						font-size: 26rpx;
					}
				}
			}
		}

		.address_info_box {
			padding: 38rpx 60rpx;

			.address_info_title {
				font-size: 32rpx;
				padding-left: 12rpx;
				padding-bottom: 15rpx;
				border-bottom: 1rpx solid #E9E9E9;
			}

			.address_info {
				padding: 0 12rpx;
			}

			.step_select {
				.uni-select {
					font-size: 26rpx;
					height: 86rpx !important;
				}
			}
		}

		.ticket_pic {
			width: 240rpx;
			height: 240rpx;
			vertical-align: middle;
		}

		.download_qrcode_pic {
			width: 52rpx;
			height: 52rpx;
			vertical-align: middle;
		}
	}
</style>